///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_MAT_FUNCTIONS_H_
#define _BUOLA_MAT_FUNCTIONS_H_

#include <buola/mat/cexpr.h>
#include <buola/mat/detail/celementunaryop.h>
#include <buola/functors/transform/math.h>
#include <buola/functors/predicates/math.h>

namespace buola { namespace mat {

///\todo see if it is better to make these functions inline
    
template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::AAbs>
abs(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::abs;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::ALog>
log(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::log;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::ASin>
sin(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::sin;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::ACos>
cos(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::cos;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::AExp>
exp(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::exp;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::ASqrt>
sqrt(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::sqrt;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::ASq>
sq(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::sq;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::APowConstant<detail::OScalar<tLH>>>
pow(const CExpr<tLH> &pLH,detail::OScalar<tLH> pRH)
{
    return {pLH.Derived(),fn::APowConstant<detail::OScalar<tLH>>(pRH)};
}

using buola::pow;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::AIsNaN>
is_nan(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::is_nan;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::AIsFinite>
is_finite(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::is_finite;

template<typename tLH>
detail::OElementUnaryOpResult<const tLH&,fn::AIsInf>
is_inf(const CExpr<tLH> &pLH)
{
    return {pLH.Derived(),{}};
}

using buola::is_inf;

/*namespace mat*/ } /*namespace buola*/ }

#endif
